# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-golang-x-term
pkgver=0.0.20220722
_commit=a9ba230a40351414fd544a412ea1f85661cc0ca8
pkgrel=1
pkgdesc='Go terminal and console support'
arch=('any')
url="https://github.com/golang/term"
license=('BSD')
depends=('go' 'golang-golang-x-sys')
source=("$pkgname-$_commit.tar.gz::https://github.com/golang/term/archive/$_commit.tar.gz")
sha512sums=('b223b994224962b45231e8a251f77aeabe38071f37c7aaf7c68fd1fc57191c5effe5c76d960227ade42232083965b7c36c22b57d175932f07040d87006da5031')

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/golang.org/x
  cp -a "$srcdir"/term-$_commit "$srcdir"/build/src/golang.org/x/term
  cd "$srcdir"/build/src/golang.org/x/term
  go test -v $(go list ./...)
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/golang.org/x
  cp -a "$srcdir"/term-$_commit "$pkgdir"/usr/share/gocode/src/golang.org/x/term

  install -Dm644 term-$_commit/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
